package com.sky.mapper;


import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {


    List<ShoppingCart> list(ShoppingCart shoppingCart);

    void updateNumberById(ShoppingCart shoppingCart);

    void insert(ShoppingCart shoppingCart);

    @Select("select * from sky_take_out.shopping_cart WHERE user_id=#{userId};")
    List<ShoppingCart> selectAll(Long userId);

    @Delete("delete from sky_take_out.shopping_cart where user_id=#{currentId}")
    void deleteAll(Long currentId);

    /**
     * 删除单个菜品
     * @param shoppingCartDTO
     */
    @Delete("delete from sky_take_out.shopping_cart where dish_id=#{dishId} and dish_flavor=#{dishFlavor}")
    void deleteSingleDish(ShoppingCartDTO shoppingCartDTO);

    @Delete("delete from sky_take_out.shopping_cart where setmeal_id=#{setmealId}")
    void deleteSingleSetmeal(ShoppingCartDTO shoppingCartDTO);

    void insertBatch(List<ShoppingCart> shoppingCarts);

}
